/*
 *  $TEAM_NAME Space Trader
 */
package presenters;

import models.Game;
import views.HubPanel; 
import views.TitlePanel;

import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * Hub Presenter
 * @author twb
 * @version 1.0
 */
public class HubPresenter extends Presenter<HubPanel> implements ActionListener {
	/**
	 * field
	 */
	private final Game game;

	/**
	 * Create a new hub presenter
	 * @param game
	 * @param view
	 */
    public HubPresenter(Game game, HubPanel view) {
        this.game = game;
        super.setView(view);

        view.addActionListener(this);
    }

    /**
     * Action performed
     * @param e
     */
    public void actionPerformed(ActionEvent e) {
        final Object source = e.getSource();

        if (source instanceof JButton) {
            final JButton button = (JButton) source;

            if ("Menu".equals(button.getText())) {
                Game.save(game);
                
                final TitlePanel titlePanel = new TitlePanel();
                final TitlePresenter titlePresenter = new TitlePresenter(titlePanel);
                
                present(titlePresenter);
            } else if ("Options".equals(button.getText())) {
                System.out.println("There are no options...");    
            }
        }
    }
    
    /**
     * to string
     * @return string
     */
    public String toString() {
		return "";
	}
}
